<?php
/**
 * Description of Login
 *
 * @author barthez
 */

class Form_Warcraft extends Zend_Form {

    public $_data = null;
    public $_maps = null;
    public $_allmaps = null;

    public function  __construct($data = null, $maps = null, $allmaps = null) {
        $this->_data = $data;
        $this->_maps = $maps;
        $this->_allmaps = $allmaps;
        return $this;
    }

    public function getForm()
    {
        $this->setMethod('POST');
        $userId = new Zend_Form_Element_Hidden('userId');

        $garena = new Zend_Form_Element_Text('garena');
        if ($this->_data) $garena->setValue($this->_data->getGarena());

        $race = new Zend_Form_Element_Select('race', array(
            'multiOptions'=> array('', 'Human'=>'Human', 'Orc'=>'Orc', 'Night Elves'=>'Night Elves', 'Undead'=>'Undead'))
        );
        if ($this->_data) $race->setValue($this->_data->getRace());
        
        $submit = new Zend_Form_Element_Submit('submit', array('label' => 'Сохранить'));
        
        $this->addElements(array($userId, $garena, $race, $submit));

      //  show($this->_maps);
        
        foreach ($this->getElements() as $element) {
            $element->setDecorators(array('viewHelper', 'Errors'));
        }

        $this->setDecorators(array(
            array('ViewScript', 
                array('viewScript' => 'warcraft/forms/index.phtml',
                      'maps'=>$this->_maps,
                      'allmaps'=>$this->_allmaps
                )
            )));

        return $this;
    }
    
  

}